﻿namespace Sgr.Email
{
    /// <summary>
    /// 邮件服务配置选项
    /// </summary>
    public class EmailOptions
    {
        #region SMTP服务器配置

        /// <summary>
        /// SMTP服务器地址
        /// </summary>
        public string Host { get; set; } = string.Empty;

        /// <summary>
        /// SMTP服务器端口
        /// </summary>
        public int Port { get; set; }

        /// <summary>
        /// 连接超时时间（秒）
        /// </summary>
        public int TimeoutSeconds { get; set; } = 30;

        /// <summary>
        /// 验证类型
        /// <para>None: 无验证</para>
        /// <para>StartTls: 使用 STARTTLS 加密</para>
        /// <para>SslOnConnect: 使用 SSL/TLS 加密</para>
        /// </summary>
        public string VerificationType { get; set; } = "TLS";

        /// <summary>
        /// 是否验证服务器证书
        /// </summary>
        public bool ValidateServerCertificate { get; set; } = false;

        #endregion SMTP服务器配置

        #region 认证信息

        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; } = string.Empty;

        /// <summary>
        /// 密码/授权码
        /// </summary>
        public string Password { get; set; } = string.Empty;

        /// <summary>
        /// 认证类型
        /// </summary>
        public SmtpAuthenticationType AuthenticationType { get; set; } = SmtpAuthenticationType.Basic;

        #endregion 认证信息

        #region 发送配置

        /// <summary>
        /// 默认发件人邮箱地址
        /// </summary>
        public string DefaultFromAddress { get; set; } = "";

        /// <summary>
        /// 默认发件人显示名称
        /// </summary>
        public string DefaultFromDisplayName { get; set; } = "";

        #endregion 发送配置

        #region 并发与重试设置

        /// <summary>
        /// 最大重试次数
        /// </summary>
        public int MaxRetryCount { get; set; } = 3;

        /// <summary>
        /// 重试间隔（秒）
        /// </summary>
        public int RetryIntervalSeconds { get; set; } = 5;

        /// <summary>
        /// 发送限制（每分钟）
        /// </summary>
        public int RateLimit { get; set; } = 60;

        #endregion 并发与重试设置

        /// <summary>
        /// 创建默认配置
        /// </summary>
        public static EmailOptions CreateDefault()
        {
            return new EmailOptions();
        }
    }
}